<!DOCTYPE html>
<html lang="es">
	<head>
		<title>{{ titulo_pagina }}</title>
		<meta charset="utf-8">
		<meta name="keywords" content="cartera, estudiantes, matriculas" /> 
		<meta name="description" content="Bienvenidos a Cartera." /> 
		<meta name="generator" content="Arawak - Cartera" /> 
		<link rel="shortcut icon" href="{{ path }}images/favicon.ico"/>

        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        
        <!-- Styles -->
        <link href="{{ path }}css/bootstrap.css" rel="stylesheet">
        <link href="{{ path }}css/bootstrap-responsive.css" rel="stylesheet">
        <link href="{{ path }}css/bootstrap-overrides.css" rel="stylesheet">
        <link href="{{ path }}css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet">
        <link href="{{ path }}css/slate.css" rel="stylesheet">
        <link href="{{ path }}css/slate-responsive.css" rel="stylesheet">
        
        <!-- Javascript -->
        <script src="{{ path }}js/jquery-1.7.2.min.js"></script>
        <script src="{{ path }}js/jquery-ui-1.8.21.custom.min.js"></script>
        <script src="{{ path }}js/jquery.ui.touch-punch.min.js"></script>
        <script src="{{ path }}js/bootstrap.js"></script>
        
        <script src="{{ path }}js/Slate.js"></script>
        {% block head %}{% endblock %}
        
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
		<script type="text/javascript">
		  var _gaq = _gaq || [];
		  _gaq.push(['_setAccount', 'UA-5384954-16']);
		  _gaq.push(['_trackPageview']);
		
		  (function() {
			var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		  })();
		
		</script>
		<script type="text/javascript">
			$(document).ready(function()
			{

                // using jQuery
				function getCookie(name) {
					var cookieValue = null;
					if (document.cookie && document.cookie != '') {
						var cookies = document.cookie.split(';');
						for (var i = 0; i < cookies.length; i++) {
							var cookie = jQuery.trim(cookies[i]);
							// Does this cookie string begin with the name we want?
							if (cookie.substring(0, name.length + 1) == (name + '=')) {
								cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
								break;
							}
						}
					}
					return cookieValue;
				}
				var csrftoken = getCookie('csrftoken');
				
				function csrfSafeMethod(method) {
					// these HTTP methods do not require CSRF protection
					return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
				}
				function sameOrigin(url) {
					// test that a given url is a same-origin URL
					// url could be relative or scheme relative or absolute
					var host = document.location.host; // host + port
					var protocol = document.location.protocol;
					var sr_origin = '//' + host;
					var origin = protocol + sr_origin;
					// Allow absolute or scheme relative URLs to same origin
					return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
						(url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') ||
						// or any other URL that isn't scheme relative or absolute i.e relative.
						!(/^(\/\/|http:|https:).*/.test(url));
				}
				$.ajaxSetup({
					beforeSend: function(xhr, settings) {
						if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) {
							// Send the token to same-origin, relative URLs only.
							// Send the token only if the method warrants CSRF protection
							// Using the CSRFToken value acquired earlier
							xhr.setRequestHeader("X-CSRFToken", csrftoken);
						}
					}
				});
				
				{% block jquery %}{% endblock %}
			});
			
			{% block javascript %}{% endblock %}
		</script>
	</head>
 	
	<body>
    	<div id="header">
            <div class="container">			
                <h1><a href="./">Arawak - Inventarios 2.0</a></h1>
				{% if request.session.config.configuracion.version_producto %}
					<h3>{{ request.session.config.configuracion.version_producto }}</h3>
				{% endif %}
				<div id="info">
                    <a href="javascript:;" id="info-trigger">
                        <i class="icon-cog"></i>
                    </a>
                    {% if user.is_authenticated %}
                        <div id="info-menu">
                            <div class="info-details">
                                <h4>Bienvenido, {{ user.first_name }}</h4>
                                <p>
                                    Registrado como Admin.
                                    <br>
                                    {% block notificaciones %}			
                                    {% endblock %}
                                    <a href="/logout/">Cerrar sesión</a>
                                </p>
                            </div> <!-- /.info-details -->
                            <div class="info-avatar">
                            
                            	{% if request.session.config.configuracion.logo %}
                                	<img src="{{ path }}{{ request.session.config.configuracion.logo }}" alt="avatar">
                                {% else %}
									<img src="{{ path }}img/logo.jpg" alt="avatar">
                                {% endif %}
                                
                            </div> <!-- /.info-avatar -->
                        </div> <!-- /#info-menu -->
					{% endif %}
                </div> <!-- /#info -->
            </div> <!-- /.container -->
        </div> <!-- /#header -->

		{% if user.is_authenticated %}
        <div id="nav">
            <div class="container">
                <a href="javascript:;" class="btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <i class="icon-reorder"></i>
                </a>
                <div class="nav-collapse">
                    <ul class="nav">
                        <li class="nav-icon active">
                            <a href="/">
                                <i class="icon-home"></i>
                                <span>Inicio</span>
                            </a>	    				
                        </li>
                        
                        <li class="nav-icon active">					
                            <a href="/inventario/proveedores">
                                <i class="icon-copy"></i>Proveedores</a>
                        </li>
                        <!--
                        <li class="nav-icon active">					
                            <a href="/inventario/productos">
                                <i class="icon-copy"></i>Productos</a>
                        </li>
                        -->
                        
                        <li class="dropdown">                   
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="icon-copy"></i>
                                Productos
                                <b class="caret"></b>
                            </a>    
                        
                            <ul class="dropdown-menu">
                                <li><a href="/inventario/productos">Administrar productos</a></li>
                            </ul>                   
                        </li>
                        
                        <li class="dropdown">                   
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="icon-copy"></i>
                                Entrada de productos
                                <b class="caret"></b>
                            </a>    
                        
                            <ul class="dropdown-menu">
                                <li><a href="/inventario/facturas_compra">Facturas de compra</a></li>
                                <li><a href="/inventario/orden_entrada">Orden de entrada</a></li>
                                <li><a href="/inventario/reintegro">Reingreso de producto</a></li>
								<li><a href="/inventario/orden_factura">Orden en Factura</a></li>
								<li><a href="/inventario/prueba_correo">Prueba correo integración</a></li>
                            </ul>                   
                        </li>
						
						<li class="dropdown">                   
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="icon-copy"></i>
                                Salida de productos
                                <b class="caret"></b>
                            </a>    
                        
                            <ul class="dropdown-menu">
                                <li><a href="/inventario/devolucion">Devolución</a></li>
								<li><a href="/inventario/facturas_venta">Facturas de venta</a></li>
                                <li><a href="/inventario/obsequio">Obsequios</a></li>
                                <li><a href="/inventario/prestamo">Préstamo</a></li>
                                <li><a href="/inventario/traslados">Traslados</a></li>
                            </ul>                   
                        </li>
						
						<li class="dropdown">                   
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="icon-copy"></i>
                                Reportes
                                <b class="caret"></b>
                            </a>    
                        
                            <ul class="dropdown-menu">
								<li><a href="/inventario/inventario">Inventario</a></li>
                                <li><a href="/inventario/informe_sismed">Informe al Sismed</a></li>
								<li><a href="/inventario/producto_proveedor">Producto Proveedor</a></li>
								<li><a href="/inventario/consumo_productos">Consumo de productos</a></li>
                            </ul>                   
                        </li>

                        {% for grupo in user.groups.all %}
                            {% if grupo.id == 1 %}
                                <li class="dropdown">                   
                                    <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                        <i class="icon-copy"></i>
                                        Configuración
                                        <b class="caret"></b>
                                    </a>    
                                
                                    <ul class="dropdown-menu">
                                        <li><a href="/configuracion">Configurar sistema</a></li>
                                        <!--<li><a href="/configuracion/backup">Backup</a></li>-->
                                        <li><a href="/configuracion/usuarios">Administrar usuarios</a></li>
                                    </ul>                   
                                </li>
                            {% endif %}
                        {% endfor %}
                        

                    </ul>
                    
                </div> <!-- /.nav-collapse -->
                
            </div> <!-- /.container -->
            
        </div> <!-- /#nav -->
        <div class="content">
            <div class="container">
                <div class="row">
                {% block contenido %}
                                    
                {% endblock %}
                </div>
            </div>
		</div>
        {% else %}
                {% block contenido2 %}
                                    
                {% endblock %}
        {% endif %}
        <footer>     
		{% if debug %}
		<!-- Debug Consults lentas -->
			<div id="debug">
				<h2>Consultas</h2>
				<p>
					{{ sql_queries|length }} Quer{{ sql_queries|pluralize:"y,ies" }}
					{% ifnotequal sql_queries|length 0 %}
						(<span style="cursor: pointer;" onclick="var s=document.getElementById('debugQueryTable').style;s.display=s.display=='none'?'':'none';this.innerHTML=this.innerHTML=='Show'?'Hide':'Show';">Show</span>)
					{% endifnotequal %}
				</p>
				<table id="debugQueryTable" style="display: none;">
					<col width="1"></col>
					<col></col>
					<col width="1"></col>
					<thead>
						<tr>
							<th scope="col">#</th>
							<th scope="col">SQL</th>
							<th scope="col">Tiempo</th>
						</tr>
					</thead>
					<tbody>
						{% for query in sql_queries %}
							<tr class="{% cycle odd,even %}">
								<td>{{ forloop.counter }}</td>
								<td>{{ query.sql|escape }}</td>
								<td>{{ query.time }}</td>
							</tr>
						{% endfor %}
					</tbody>
				</table>
			</div>
		{% endif %}
        </footer>
	</body>
</html>